<?php if (!defined('THINK_PATH')) exit();?><style>
	#add_Rule_form input , #modify_Rule_form input{
		width:200px;
	}
	#modify_Rule_form select,#add_Rule_form select {
		width:95px;
	}
	#add_Rule_form td ,#modify_Rule_form td{
		height: 30px;
	}
</style>
<!-- 工具栏 -->
<div id="tool-rule">    
<table>
    <tr>
        <td>
            <a href="#" id="aaa1" class="easyui-linkbutton" onclick='show_add_cj()' data-options="iconCls:'icon-standard-folder-add',plain:true">新建车间</a>
            <a href="#" id="aaa1" class="easyui-linkbutton" onclick='show_add_gw()' data-options="iconCls:'icon-standard-folder-page',plain:true">新建班组、工位</a>
            <a href="#" id="aaa1" class="easyui-linkbutton" onclick='del_cj()' data-options="iconCls:'icon-standard-page-white-delete',plain:true">删除</a>
            <a href="#" id="aaa1" class="easyui-linkbutton" onclick='show_modify_cj()' data-options="iconCls:'icon-standard-application-edit',plain:true">修改</a>
         
        </td>
    </tr>
</table>
</div>
<!-- 工具栏end -->
<!-- 新建菜单对话框 -->
<div id="add_cj_dialog" class="easyui-dialog" style="width:320px; height: 125px; padding: 10px 50px; overflow: hidden;" title="新建工位" data-options="iconCls:'icon-standard-folder-page',buttons:'#add_cj_tool',closed:true,resizable:false,modal:true,closable:true">
	<form id="add_cj_form" method="post">
	<input type="hidden" id="pid" name="pid"/>
	    	<table cellpadding="5">
	    		<tr>
	    			<td>名称:</td>
	    			<td><input class="easyui-textbox" type="text" id="title" name="title" data-options="required:true,prompt:'请输入车间、班组、工位名称'"  /></td>
	    		</tr>		    		
	    	</table>
	    </form>

</div>
<div id="add_cj_tool">
	<div class="tool_tip">添加后会在列表中出现！！</div>
	<a href="#" id="addok" class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
		onclick="add_cj()">确认</a>
	<a href="#" class="easyui-linkbutton"
		data-options="iconCls:'icon-cancel'"
		onclick="javascript:$('#add_cj_dialog').dialog('close')">取消</a>
</div>
<!-- 新建菜单对话框 end-->

<!-- 修改菜单对话框 -->
<div id="modify_cj_dialog" class="easyui-dialog" style="width:307px; height: 131px; padding: 10px 50px; overflow: hidden;" title="修改工位" data-options="iconCls:'icon-standard-application-edit',buttons:'#modify_cj_tool',closed:true,resizable:false,modal:true,closable:true">
	<form id="modify_cj_form" method="post">
			<input type="hidden" id="id" name="id"/>
	    	<table cellpadding="5">
	    		<tr>
	    			<td>名称:</td>
	    			<td><input class="easyui-textbox" type="text" id="title" name="title" data-options="required:true,prompt:'请输入工位名称'"  /></td>
	    		</tr>
	    	</table>
	    </form>

</div>
<div id="modify_cj_tool">
	<div class="tool_tip">添加后会在列表中出现！！</div>
	<a href="#" id="modifyok" class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
		onclick="modify_cj()">确认</a>
	<a href="#" class="easyui-linkbutton"
		data-options="iconCls:'icon-cancel'"
		onclick="javascript:$('#modify_cj_dialog').dialog('close')">取消</a>
</div>


	
<!-- <div id="iconDialog" class="easyui-dialog" title="My Dialog" style="width:675px;height:399px;"   
        data-options="iconCls:'icon-standard-folder-page',buttons:'#iconDialog_tool',closed:true,resizable:true,modal:true,closable:true">   
    

    <div class="easyui-layout" data-options="fit:true">   
      <div id="content" data-options="region:'center',border:false,title:'',href:'/solve/index.php/Admin/Public/icon?page=1',loadingMessage:'正在载入图标……'" style="padding:5px;">
      </div> 
        <div data-options="region:'south',title:'',split:false,border:false" style="height:35px;" >     
            <div class="easyui-pagination" style="border:1px solid #ccc;"
                data-options="total: 1008,pageSize: 250,pageList: [10,20,50,250],onSelectPage: function(pageNumber,pageSize){$('#content').panel('refresh', '/solve/index.php/Admin/Public/icon?page='+pageNumber+'&pageSize='+pageSize);}">
            </div>
        </div>   
      
    </div>  



</div> 
<div id="iconDialog_tool">
    <div class="tool_tip" id="myIcon">请选择合适的图标</div>
    <input type="hidden" id='aIcon'/>
    <input type="hidden" id='inputIcon'/>
    <input type="hidden" id='iconVal'/>
    <a href="#" id="modifyok" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="setIcon()">确认</a>
    <a href="#" class="easyui-linkbutton"
        data-options="iconCls:'icon-cancel'"
        onclick="javascript:$('#iconDialog').dialog('close')">取消</a>
</div>
 -->

<table id="tremlist" data-options="fit:true"></table>

<script>
	$('#tremlist').treegrid({    
    url:'/solve/index.php/Admin/Trem/tremTree',    
    idField:'id', 
    lines: true,
    rownumbers: true,   
    treeField:'title',
    nowrap : true,
    pagination : true,
    fitColumns : true,
    tool:'tool-rule',  
    autoRowHeight : true, 
    striped : true,//交替行
    singleSelect : true,//只允许选择一行
    border : false,
    columns:[[    
        {field:'id',checkbox : true},
        {field:'title',title:'名称',width:200} 

    ]],
        onDblClickCell : function(field, row) {
                         
                                     // if(field=="ordernumber"){
                                     //   $('#tremlist').treegrid('beginEdit', row.id) 
                                     // }  
                                }    
});
// 新建父菜单窗口
function show_add_cj(){
        $('#add_cj_form').form('load', {
            pid:0,
            title : ''
        });
     
        $('#add_cj_dialog').dialog("open").dialog('setTitle', '&nbsp;&nbsp;新建车间');
}

// 新建子权限窗口
function show_add_gw(){
    var row = $('#tremlist').treegrid("getSelected");
    if(!row){
        $.messager.alert('新建班组、工位', '没有选择父节点！', 'info');
      

    }else{

   
            $('#add_cj_form').form('load', {
            pid:row.id,
            title : ''
        });
          
        $('#add_cj_dialog').dialog("open").dialog('setTitle', '&nbsp;&nbsp;新建工位');
      
  
           
   
    }    
}

// 新建菜单
function add_cj(){
    $('#add_cj_form').form('submit', {

            url : '/solve/index.php/Admin/Trem/addTrem',

            success : function(data) {
                $("#tremlist").treegrid("reload");

                $.messager.alert('新建工位', data, 'info');
                $('#add_cj_dialog').dialog('close')

            }
        });
}
// 删除菜单
function del_cj(){
      var row = $('#tremlist').treegrid("getSelected");
    if(!row){
        $.messager.alert('删除菜单', '请选择要删除的工位！', 'info');
      

    }else{

        $.messager.confirm('确认','您确认想要删除“'+row.title+'”吗？',function(r){    
            if (r){    
                $.post('/solve/index.php/Admin/Trem/del', {
                            id : row.id
                        }, function(data) {
                            if (data.status==1) {
                                $.messager.alert('删除权限', data.data, 'info');
                                $("#tremlist").treegrid("reload");
                            } else {
                                $.messager.show({ // show error message  
                                    title : '错误',
                                    msg : data.data
                                });

                            }
                        }, 'json');  
            }    
        }); 
           
   
    }    
}

/**
 * 修改菜单窗口
 */
function show_modify_cj(){
     var row = $('#tremlist').treegrid("getSelected");
    if(!row){
        $.messager.alert('修改菜单', '请选择要修改的工位！', 'info');
    }else{
            $("#modify_cj_form").form("load", row);
            $("#modify_cj_dialog").dialog("open").dialog('setTitle', '&nbsp;&nbsp;修改工位');
     
        }
  
           
   
    }   

/**
 * 修改菜单
 */
function modify_cj(){
    
    $('#modify_cj_form').form('submit', {
    type:'POST',
     url : '/solve/index.php/Admin/Trem/modify',
    success : function(data) {
        $("#tremlist").treegrid("reload");
        $.messager.alert('修改工位', data, 'info');
        $('#modify_cj_dialog').dialog('close')
        // 

    }
});

}



</script>